#ifndef MAP_H
#define MAP_H

#include <QGraphicsScene>

#include "player.h"
#include "collision.h"
#include <QtCore/QtCore>
#include "connectionplayer.h"

class Player;

class Map : public QGraphicsScene
{
    Q_OBJECT
public:
    Map(qreal x, qreal y, qreal w, qreal h, bool isServerMap = false, QObject* parent = 0);

    void addObstacle(QVector<QPointF> points);
    void addPlayer(Player* player, bool isRemote = false, Mouse* mouse = NULL);
    void removePlayers();
    void removePlayer(quint16 id);
    QRectF boundingRect();
    void addSpawPoint(QPointF point);
    QVector<ConnectionPlayer*> spawnPlayers();

    void updateBullets();
    void updateBullets(Player*);

private:
    QTimer *timer;
    void setBoundingRect(QRectF r);
    qreal start_x, start_y;
    qreal pwidth, pheight;
    QVector<Player*> players;
    QVector<QPointF> spawPoints;


private slots:
	void updateMap();
    void collidePlayer(Player* player);
    void onHitPlayer(Player*, Player*);

signals:
    void hitPlayer(Player*, Player*);
};

#endif // MAP_H
